package com.enjoyor.soa.traffic.server.tsms.dubbo.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.enjoyor.soa.traffic.api.dto.tsms.CommonPlaceDto;
import com.enjoyor.soa.traffic.api.dto.tsms.TemplateDto;
import com.enjoyor.soa.traffic.api.service.dubbo.tsms.IDubboCommonPlaceService;
import com.enjoyor.soa.traffic.core.tsms.domain.CommonPlace;
import com.enjoyor.soa.traffic.core.tsms.domain.Template;
import com.enjoyor.soa.traffic.core.tsms.service.ICommonPlaceService;
import com.enjoyor.soa.traffic.util.enums.EnumAppCode;
import com.enjoyor.soa.traffic.util.helper.ReflectHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@SuppressWarnings("rawtypes")
@Service(version = "1.0.0", timeout = 4000)
public class DubboCommonPlaceService implements IDubboCommonPlaceService{
	@Autowired 
	private ICommonPlaceService iCommonPlaceService; 
	
	@Override
	public ResultPojo selectPage(Page page,String commonPlaceId,String commonPlaceName,String placeTypeId,String placeTypeName,String placeAddress,String createPerson,String createTime,String placePerson) {
		// TODO Auto-generated method stub
		 return new ResultPojo(iCommonPlaceService.getCommonPlacePage(page,commonPlaceId,commonPlaceName,placeTypeId,placeTypeName,placeAddress,createPerson,createTime,placePerson));
	}

	@Override
	public ResultPojo selectList(String commonPlaceId,String commonPlaceName,String placeTypeId,String placeTypeName,String placeAddress,String createPerson,String createTime,String placePerson) {
		// TODO Auto-generated method stub
		List<CommonPlace> list = iCommonPlaceService.getCommonPlaceList(commonPlaceId,commonPlaceName,placeTypeId,placeTypeName,placeAddress,createPerson,createTime,placePerson);
		return new ResultPojo(ReflectHelper.listToList(list, CommonPlaceDto.class));
	}

	@Override
	public ResultPojo insert(CommonPlaceDto commonPlaceDto, String personName) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		String commonPlaceId = iCommonPlaceService.insert(ReflectHelper.beanToBean(commonPlaceDto, CommonPlace.class), personName);
		if( !"false".equals(commonPlaceId) ) {
			resultPojo = new ResultPojo(commonPlaceId);
		}else {
			resultPojo = new ResultPojo(EnumAppCode.PARAM_ERR, "类型参数错误！");
		}
		return resultPojo;
	}

	@Override
	public ResultPojo update(CommonPlaceDto commonPlaceDto, String personName) {
		// TODO Auto-generated method stub
		iCommonPlaceService.update(ReflectHelper.beanToBean(commonPlaceDto, CommonPlace.class), personName);
		return new ResultPojo();
	}

	@Override
	public ResultPojo delete(String commonPlaceId, String personName) {
		// TODO Auto-generated method stub
		iCommonPlaceService.delete(commonPlaceId, personName);
		return new ResultPojo();
	}

}
